import { DETAILSHOW, DETAILCLOSE} from './projectDetailConstant'

// preState是旧状态，action是动作对象
function ProjectDetailReducer(preState: any, action: any) {
  if (preState === undefined) return null;
  // 解构出action动作对象中的两个属性赋给type和data变量
  const { type, data } = action
  switch (type) {
    case 'DETAILSHOW':
      // 相关操作
      return {
        ...preState,
        projectDetail: data
      }
    case 'DETAILCLOSE':
      // 相关操作
      return {
        ...preState,
        projectDetail: []
      }
    default:
      return preState;
  }
}
export default ProjectDetailReducer;
